<%@ page pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://www.ld.com/shield/tags" prefix="shield"%>
<%@ taglib uri="http://www.ld.com/system/tags" prefix="system"%>
<%@ page trimDirectiveWhitespaces="true" %>
<fmt:setLocale value="zh_CN"/>
<%-- 权限判断 --%>
<shield:permssion type="button">
<form action="${ctxPathA}/system/sensitivewordset/propertiesUpdate" method="post" autocomplete="off" class="show-info">
	<shield:token></shield:token>
	<input type="hidden" name="key" value="${model.key}" >
    <table class="tab-show">
    	<colgroup>
    		<col width="20%">
    		<col width="">
    	</colgroup>
        <tr>
	    	<th>
            	<label>名称：</label>
        	</th>
         	<td>${model.key}</td>
		<tr>
        <tr>
	    	<th>
            	<label>值：</label>
        	</th>
         	<td>
<c:choose>
	<%-- 字典库类型，文件或数据库 --%>
	<c:when test="${key == 'sensitiveword.type' }">
		<c:forEach var="entry" items="${serviceTypeKeys }">
         		<input type="radio" name="value" value="${entry}" class="radio" ${model.value==entry?"checked":""}>${entry}
		</c:forEach>
	</c:when>
	<%-- 内置字典库 --%>
	<c:when test="${key == 'sensitiveword.dict' }">
				<input type="text" name="value" value="${model.value}" class="input dictsEmbedInput">
		<c:forEach items="${dictsAllEmbedMap}" var="entry">
         		<input type="checkbox" value="${entry.key}" class="check dictsAllEmbedCheckBox" ${entry.value?"checked":""}>${entry.key}
		</c:forEach>
         		<span class="tips"> 注：点击选择的顺序决定了保存顺序。</span>
	</c:when>
	<%-- 扩展字典库 --%>
	<c:when test="${key == 'sensitiveword.ext_dict' }">
         		<textarea name="value">${model.value}</textarea>
         		<span class="tips"> 注：多个值用英文逗号  （即 ,  ）连接。</span>
	</c:when>
	<%-- 处理器类型 --%>
	<c:when test="${key == 'sensitiveword.handler' }">
		<c:forEach var="entry" items="${handlerTypeKeys }">
         		<input type="radio" name="value" value="${entry}" class="radio" ${model.value==entry?"checked":""}>${entry}
		</c:forEach>
	</c:when>
	<c:otherwise >
         		<input type="text" name="value" value="${model.value}" class="input">
	</c:otherwise>
</c:choose>
         	</td>
		<tr>
    </table>
    <div class="taCenter">
		<input class="button" type="submit" value="提交"/>
    	<input class="button default" type="reset" value="重置"/>
    </div>
    <script type="text/javascript">
    	$(".dictsAllEmbedCheckBox").change(function(){
    		var $this = $(this);
    		var checked = $this.prop("checked");
    		var thisv = $this.val();
    		var dictsEmbedInputE = $(this).closest("td").find(".dictsEmbedInput");
    		var valueArrs = [];
    		if(dictsEmbedInputE.val()){
    			valueArrs = dictsEmbedInputE.val().split(",");
    		}
    		if(checked){
    			valueArrs.push(thisv);
    		} else {
    			valueArrs = valueArrs.filter(function(item) {
    			     return item != thisv;
    			});
    		}
    		var value = valueArrs.join(",");
   			dictsEmbedInputE.val(value);
    	});
    </script>
</form>
</shield:permssion>